package plenprojects.security;

import java.math.BigInteger;
import java.security.MessageDigest;

public class MD5PasswordEncoder implements PasswordEncoder {
	
	private String salt = "";
	
	public String encode(String password) {
		
		MessageDigest dig = null;
		
		try {
			
			dig = MessageDigest.getInstance("MD5");
		}
		catch(Exception e) {}
		
		String eatMe = password + salt;
		
		dig.update(eatMe.getBytes());
		
		BigInteger big = new BigInteger(1, dig.digest());
		
		return big.toString(16);
	}

	public void setSalt(String salt) {
		
		this.salt = salt;
	}

}
